package com.zhengsr.festec;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.View;

import com.zhengsr.latte.delegates.LatteDelegate;
import com.zhengsr.latte.net.RestClient;
import com.zhengsr.latte.net.callback.RestListenerAdapter;

/**
 * Created by zhengshaorui on 2018/3/7.
 */

public class MainDelagete extends LatteDelegate {
    private static final String TAG = "MainDelagete";
    @Override
    public Object getLayout() {
        return R.layout.delegate_main;
    }

    @Override
    public void initView(@Nullable Bundle savedInstanceState, View view) {
        Log.d(TAG, "zsr --> initView: ");
        RestClient restClient = new RestClient.Builder()
                .setUrl("http://127.0.0.1/index")
                .setListenerAdapter(new RestListenerAdapter() {
                    @Override
                    public void onSuccess(String reposonse) {
                        super.onSuccess(reposonse);
                        Log.d(TAG, "zsr --> onSuccess: "+reposonse.toString());
                        Log.d(TAG, "zsr --> onSuccess: ");
                    }

                    @Override
                    public void onFailure(String msg) {
                        super.onFailure(msg);
                        Log.d(TAG, "zsr --> onFailure: ");
                    }

                    @Override
                    public void onError(int code, String errormsg) {
                        super.onError(code, errormsg);
                        Log.d(TAG, "zsr --> onError: ");
                    }

                    @Override
                    public void onRequestStart() {
                        super.onRequestStart();
                        Log.d(TAG, "zsr --> onRequestStart: ");
                    }

                    @Override
                    public void onRequestEnd() {
                        super.onRequestEnd();
                        Log.d(TAG, "zsr --> onRequestEnd: ");
                    }
                })
                .builder()
                .get();


    }


}
